﻿Imports System.Data.OleDb
Partial Public Class ChooseSlots
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       
    End Sub

    Protected Sub btn_submit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_submit.Click
        Dim item As ListItem
        Dim conn As New OleDbConnection(ConfigurationManager.ConnectionStrings("AppointmentsConnectionString").ToString())
        For Each item In CheckBoxList1.Items
            Dim sql As String = "INSERT INTO FreeSlots(Lecturer, AppointmentSlots) VALUES(@Lecturer, @AppointmentSlots)"
            Dim cmd As New OleDbCommand(sql, conn)
            If item.Selected = True Then
                conn.Open()
                cmd.Parameters.AddWithValue("@Lecturer", User.Identity.Name)
                cmd.Parameters.AddWithValue("@AppointmentSlots", item.Value)
                Label1.Text = Label1.Text.ToString & item.Text & "<BR>"
                cmd.ExecuteNonQuery()
                conn.Close()
            End If
        Next



    End Sub
End Class